	#pragma warning(disable:4996)
	#include<stdio.h>
	int main()
	{
		int m, n, tmp;
		scanf("%d,%d", &m, &n);
		while (m % n){
			tmp = m % n; 
			m = n;
			n = tmp;
		}
		printf("%d", n);
		return 0;

	}
